package view;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import entity.Book;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.TableModelListener;

/**
 * @author s759487
 * @version 1.0
 * @created 11-Apr-2011 16:31:11
 */
public class DetailView extends JFrame {

    /**
     *
     */
    private static final long serialVersionUID = -5129650954233150579L;
    private Book book;

    private JLabel reserveLabel = new JLabel("Name: ");
    private JTextField reservedBy = new JTextField();
    private JButton reserveButton = new JButton("Reserve this book");


    public DetailView(Book b, TableModelListener tbl) {
        setLayout(new BorderLayout());
        this.book = b;
        setSize(600, 200);
        String[] headlines = {"Id", "Author", "Title", "Borrowed by", "Reserved By"};
        Object[][] data = new Object[1][5];
        data[0][0] = b.getId() + "";
        data[0][1] = b.getAuthor();
        data[0][2] = b.getTitle();
        data[0][3] = b.getLentTo();
        data[0][4] = b.getReservedBy();
        JTable jt = new JTable(data, headlines);
        jt.getModel().addTableModelListener(tbl);
        JScrollPane js = new JScrollPane(jt);
        add(js);
        //add(reserveLabel, BorderLayout.WEST);
        //add(reservedBy, BorderLayout.CENTER);
        //add(reserveButton, BorderLayout.EAST);
        setVisible(true);
    }

    public Book getBook() {
        return null;
    }

    /**
     *
     * @param book
     */
    public void setBook(Book book) {
    }
}
